// 处理富文本展示
function formatRichText(html) {
  if(!html) return ''
  // eslint-disable-next-line no-unused-vars
  let newContent = html.replace(/<img[^>]*>/gi, function (match, capture) {
    match = match.replace(/style="[^"]+"/gi, "").replace(/style='[^']+'/gi, "");
    match = match
      .replace(/height='[^']+'/gi, "");
    return match;
  });
  // eslint-disable-next-line no-unused-vars
  newContent = newContent.replace(/style="[^"]+"/gi, function (match, capture) {
    match = match
      .replace(/width:[^;]+;/gi, "width:100%;");
    return match;
  });
  newContent = newContent.replace(/<br[^>]*\/>/gi, "");
  // eslint-disable-next-line no-useless-escape
  newContent = newContent.replace(
    /\<img/gi,
    '<img style="width:100%;height:auto;display:block;margin-top:0;margin-bottom:0;"'
  );
  return newContent;
}
export default formatRichText;
